package top.tagao.m02_creationalPatterns.c_01_builder;

import top.tagao.m02_creationalPatterns.c_01_builder.builders.CarBuilder;
import top.tagao.m02_creationalPatterns.c_01_builder.builders.CarManualBuilder;
import top.tagao.m02_creationalPatterns.c_01_builder.cars.Car;
import top.tagao.m02_creationalPatterns.c_01_builder.cars.Manual;

/**
 * @author fu-xiao-liu
 * @Date 2022/7/23 11:37
 * 产品角色（Product）：Phone
 * 抽象建造者（Builder）：AbstractPhoneBuilder
 * 具体建造者(Concrete Builder）：PhoneBuilder
 * 指挥者（Director）类定义调用构造步骤的顺序 、隔离客户与对象的生产过程
 * 创建和复用特定的产品配置。
 * 创建的东西细节复杂，还必须暴露给使用者。屏蔽过程而不屏蔽细节
 */
public class Main {
    public static void main(String[] args) {
        Director director = new Director();

        CarBuilder carBuilder = new CarBuilder();
        director.constructSportsCar(carBuilder);

        Car car = carBuilder.getResult();
        System.out.println("Car built:\n" + car.getCarType());

        CarManualBuilder carManualBuilder = new CarManualBuilder();
        director.constructSportsCar(carManualBuilder);
        Manual carManual = carManualBuilder.getResult();
        System.out.println("\nCar manual built:\n" + carManual.toString());
    }
}
